<?php

require_once 'BetterValidation.php';

$myrules = array('name'           => 'min_length[4]',
                 'username'       => 'required|min_length[4]|max_length[128]',
                 'password'       => 'required|min_length[4]',
                 'passconf'       => 'required|matches[password]',
                 'email'          => 'required|valid_email',
                 'account_number' => 'required|regex[/[\d]+\-[A-Z]{4}\-[\d]{2}/]');

$rules = new ValidationRules($myrules);

$data = array('name'           => 'me',
              'username'       => 'koorb',
              'password'       => 'MyPåssw00rd',
              'passconf'       => 'MyPåssw00rd',
              'email'          => 'richard@koorb.co.uk',
              'account_number' => '1-ABCD-23');

try {
    var_dump($rules->validate($data, false));
    printf('<p>There were %d errors</p>', $rules->countErrors());
    var_dump($rules->getErrors());
} catch (Exception $e) {
    print $e->getMessage();
}